package com.ruoyi.common.config;

import org.springframework.amqp.core.*;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author: jsd
 * @create: 2024-09-06 09:42
 */
@Configuration
public class RabbitMqConfig {

    //用户交换机名称
    public static final String EXCHANGE_USER_NAME = "jiekee_user_exchange";

    //用户队列名称
    public static final String QUEUE_USER_NAME = "jiekee_user_queue";

    //骑手未揽收交换机名称
    public static final String EXCHANGE_DELIVER_NO_GET_NAME
            = "jiekee_deliver_no_get_exchange";

    //骑手未揽收用户队列名称
    public static final String QUEUE_DELIVER_NO_GET_NAME
            = "jiekee_deliver_no_get_queue";

    //骑手未派送交换机名称
    public static final String EXCHANGE_DELIVER_NO_PUT_NAME
            = "jiekee_deliver_no_put_exchange";

    //骑手未派送用户队列名称
    public static final String QUEUE_DELIVER_NO_PUT_NAME
            = "jiekee_deliver_no_put_queue";


//    /**
//     * 创建用户交换机
//     * @return
//     */
//    @Bean("userExchange")
//    public Exchange userExchange(){
//        return ExchangeBuilder.topicExchange(EXCHANGE_USER_NAME).durable(true).build();
//    }
//
//    /**
//     * 创建用户队列
//     * @return
//     */
//    @Bean("userQueue")
//    public Queue userQueue(){
//        return QueueBuilder.durable(QUEUE_USER_NAME).build();
//    }
//
//    @Bean
//    public Binding userBinding( @Qualifier("userExchange") Exchange exchange,
//                                @Qualifier("userQueue") Queue queue){
//
//        return BindingBuilder.bind(queue).to(exchange).with("jiekee.user").noargs();
//
//    }

    /**
     * 创建骑手未揽收交换机
     * @return
     */
    @Bean("deliverNoGetExchange")
    public Exchange deliverPendingCollectionExchange(){
        return ExchangeBuilder.topicExchange(EXCHANGE_DELIVER_NO_GET_NAME).durable(true).build();
    }

    /**
     * 创建骑手未揽收队列
     * @return
     */
    @Bean("deliverNoGetQueue")
    public Queue deliverPendingCollectionQueue(){
        return QueueBuilder.durable(QUEUE_DELIVER_NO_GET_NAME).build();
    }

    @Bean
    public Binding deliverPendingCollectionBinding(
            @Qualifier("deliverNoGetExchange") Exchange exchange,
            @Qualifier("deliverNoGetQueue") Queue queue){

        return BindingBuilder.bind(queue).to(exchange).with("jiekee.deliverNoGet").noargs();

    }

//    /**
//     * 创建未派送交换机
//     * @return
//     */
//    @Bean("deliverNoPutExchange")
//    public Exchange deliverCleaningCompletedExchange(){
//        return ExchangeBuilder.topicExchange(EXCHANGE_DELIVER_NO_PUT_NAME)
//                .durable(true).build();
//    }
//
//    /**
//     * 创建未派队列
//     * @return
//     */
//    @Bean("deliverNoPutQueue")
//    public Queue deliverCleaningCompletedQueue(){
//        return QueueBuilder.durable(QUEUE_DELIVER_NO_PUT_NAME).build();
//    }
//
//    @Bean
//    public Binding deliverCleaningCompletedBinding(
//            @Qualifier("deliverNoPutExchange") Exchange exchange,
//            @Qualifier("deliverNoPutQueue") Queue queue){
//
//        return BindingBuilder.bind(queue).to(exchange).with("jiekee.deliverNoPut").noargs();
//
//    }

}
